﻿using System;
using System.Collections.Specialized;
using Ss.Model;
using Vici.Core;
using Vici.Mvc;
namespace web._Initialize
{
    /// <summary>
    /// 对象转换器
    /// </summary>
    public class DataCreateObject:IObjectBinder
    {
        /// <summary>
        /// 尝试转换对象
        /// </summary>
        /// <param name="value">值</param>
        /// <param name="objectType">对象类型</param>
        /// <param name="obj">输出对象</param>
        /// <returns></returns>
        public bool TryConvert(string value, System.Type objectType, out object obj)
        {
            if (objectType == typeof(Article))
            {
                int id = value.To<int>();
                obj = Article.Read(id);
                return (obj != null);
            }
            obj = null;
            return false;
        }

        public bool TryConvert(System.Type objectType, out object obj, NameValueCollection clientData)
        {
            throw new NotImplementedException();
        }
    }
}